<template>
  <li
    @mouseenter="isShow = 1"
    @mouseleave="isShow = 2"
  >
    <label>
      <input type="checkbox" :checked="done" @change="changeByIdDone(id)"/>
      <span>{{thing}}</span>
    </label>
    <button
      class="btn btn-danger"
      :style="{display : isShow === 1?'block':'none'}"
      @click="deleteDone(id)"
    >删除</button>
  </li>
</template>

<script lang="ts">
import {defineComponent} from "vue";
export default defineComponent({
    name:"Item",
})
</script>

<script lang="ts" setup>
import {ref} from "vue";
const isShow = ref(0)

defineProps<{
    id:string,
    thing:string,
    done:boolean,
    changeByIdDone:Function,
    deleteDone:Function
}>()
</script>

<style scoped>
/*item*/
li {
    list-style: none;
    height: 36px;
    line-height: 36px;
    padding: 0 5px;
    border-bottom: 1px solid #ddd;
}

li label {
    float: left;
    cursor: pointer;
}

li label li input {
    vertical-align: middle;
    margin-right: 6px;
    position: relative;
    top: -1px;
}

li button {
    float: right;
    display: none;
    margin-top: 3px;
}

li:before {
    content: initial;
}

li:last-child {
    border-bottom: none;
}
li .done {
    color: #666;
    text-decoration: line-through;
}
</style>